From 261aa81d0588107b3ce9fdac2d18b164b0359a26 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Thu, 16 Oct 2008 09:52:40 +0100 Subject: [PATCH] vmx: set DR7 via DOMCTL_setvcpucontext This patch is needed for a guest domain debugger to support hardware watchpoint. Signed-off-by: Kouya Shimura --- xen/arch/x86/domain.c | 3 +++ xen/arch/x86/hvm/vmx/vmx.c | 10 +++++++++- xen/include/asm-x86/hvm/hvm.h | 7 +++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 8debb7afb1..6e1498a0f1 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -575,7 +575,10 @@ int arch_set_info_guest( v->arch.guest_context.user_regs.eflags |= 2; if ( is_hvm_vcpu(v) ) + { + hvm_set_info_guest(v); goto out; + } /* Only CR0.TS is modifiable by guest or admin. */ v->arch.guest_context.ctrlreg[0] &= X86_CR0_TS; diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index 140066bf97..407b677899 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -1184,6 +1184,13 @@ static void vmx_set_uc_mode(struct vcpu *v) vpid_sync_all(); } +static void vmx_set_info_guest(struct vcpu *v) +{ + vmx_vmcs_enter(v); + __vmwrite(GUEST_DR7, v->arch.guest_context.debugreg[7]); + vmx_vmcs_exit(v); +} + static struct hvm_function_table vmx_function_table = { .name = "VMX", .domain_initialise = vmx_domain_initialise, @@ -1214,7 +1221,8 @@ static struct hvm_function_table vmx_function_table = { .msr_read_intercept = vmx_msr_read_intercept, .msr_write_intercept = vmx_msr_write_intercept, .invlpg_intercept = vmx_invlpg_intercept, - .set_uc_mode = vmx_set_uc_mode + .set_uc_mode = vmx_set_uc_mode, + .set_info_guest = vmx_set_info_guest }; static unsigned long *vpid_bitmap; diff --git a/xen/include/asm-x86/hvm/hvm.h b/xen/include/asm-x86/hvm/hvm.h index aadc025e46..a9bee16e10 100644 --- a/xen/include/asm-x86/hvm/hvm.h +++ b/xen/include/asm-x86/hvm/hvm.h @@ -128,6 +128,7 @@ struct hvm_function_table { int (*msr_write_intercept)(struct cpu_user_regs *regs); void (*invlpg_intercept)(unsigned long vaddr); void (*set_uc_mode)(struct vcpu *v); + void (*set_info_guest)(struct vcpu *v); }; extern struct hvm_function_table hvm_funcs; @@ -314,4 +315,10 @@ int hvm_virtual_to_linear_addr( unsigned int addr_size, unsigned long *linear_addr); +static inline void hvm_set_info_guest(struct vcpu *v) +{ + if ( hvm_funcs.set_info_guest ) + return hvm_funcs.set_info_guest(v); +} + #endif /* __ASM_X86_HVM_HVM_H__ */ -- 2.30.2